<%-- 
    Document   : home
    Created on : 23.4.2011, 21:43:02
    Author     : Martin Soušek
--%>

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="stripes" uri="http://stripes.sourceforge.net/stripes.tld" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>${actionBean.context.loggedUser.username}</h1>
        
        <table>
        <c:forEach items="${actionBean.context.loggedUser.trips}" var="trip">
            <tr>
                <td><c:out value="${trip.destination}" /></td>
                <td><c:out value="${trip.price}" /></td>
                <td><c:out value="${trip.priority}" /></td>
                <td><c:out value="${trip.remaining}" /></td>
                
            
            </tr>
        </c:forEach>
            </table>
        
        <table>
            <tr><td>Transactions</td></tr>
            <tr><td>Balance</td><td>${actionBean.context.loggedUser.budget.state}</td><td rowspan="4">edit</td></tr>
            <tr><td>Income</td><td>${actionBean.context.loggedUser.budget.income}</td><td></td></tr>
            <tr><td>Expense</td><td>${actionBean.context.loggedUser.budget.expense}</td><td></td></tr>
            <tr><td>Min.</td><td>${actionBean.context.loggedUser.budget.minBudget}</td></tr>
            <tr><td>Extra expenses</td></tr>
            <c:forEach items="${actionBean.context.loggedUser.budget.transactions}" var="tran">
            <tr>
                <td><fmt:formatDate pattern="dd.MM.yyyy" value="${tran.tDate}" /></td>
                <td><c:out value="${tran.amount*tran.type}" /></td>
                <td><stripes:link beanclass="cz.uhk.ppro.traveler.logic.TransactionActionBean" event="deleteTransaction">
                        <stripes:param name="transaction.id" value="${tran.id}" />
                        -
                    </stripes:link></td>
                
            
            </tr>
        </c:forEach>
            <tr>
                <td>Add
                    <stripes:form beanclass="cz.uhk.ppro.traveler.logic.TransactionActionBean">
                    <stripes:errors/>
                    <stripes:label for="transaction.amount">Amount: </stripes:label>
                    <stripes:text name="transaction.amount" id="transaction.amount"/>
                
                    <stripes:label for="transaction.type">Type</stripes:label>
                    <stripes:select name="transaction.type" id="transaction.type">
                            <stripes:option id="transaction.type" value="1" >Credit</stripes:option>
                            <stripes:option id="transaction.type" value="-1" >Debet</stripes:option>
                    </stripes:select>
                    <stripes:submit name="addTransaction">Add</stripes:submit>
                    </stripes:form>
                </td>
            </tr>
            <tr><td>Total</td><td>${actionBean.context.loggedUser.budget.total}</td></tr>
            
        </table>
        
            
            
                    
        
    </body>
</html>
